package com.bsh.erp.pro.business.action;

import com.alibaba.fastjson.JSON;
import com.bsh.erp.base.BaseAction;
import com.bsh.erp.entity.BusinessBillExt;
import com.bsh.erp.tools.HqlHelper;
import com.bsh.erp.tools.PageBean;

/**
 * 业务单
 * 业务单详情模块
 * @author guo
 */
public class BusinessExtBillAction extends BaseAction<BusinessBillExt>{
	
	private static final long serialVersionUID = 1L;

	/**
	 * 新增业务单详情
	 */
	public void addInBill(){
		try{
			businessBillExtService.save(getModel());
			outJson("成功！");
		}catch (Exception e) {
			outJson("失败！");
		}
	}
	
	/**
	 * 修改业务单详情
	 */
	public void updateInBill(){
		try{
			businessBillExtService.update(getModel());
			outJson("成功！");
		}catch (Exception e) {
			outJson("失败!");
		}
	}
	/**
	 * 获取全部业务单详情
	 * 分页 10行
	 * pageNum 页码
	 * @return JSON数据
	 */
	public void findAllInBill(){
		HqlHelper hqlHelper = new HqlHelper(BusinessBillExt.class, "businessBillExt");
		PageBean pageBean = businessBillExtService.getPageBean(pageNum, 10, hqlHelper);
		outJson(JSON.toJSONString(pageBean));
	}
	
	/**
	 * 获取未审核 未审核详情
	 * examined Y N 审核
	 * pageNum 页码
	 * @author guo
	 * @return JSON
	 */
	public void findUnInBill(){
		HqlHelper hqlHelper = new HqlHelper(BusinessBillExt.class, "businessBillExt").addWhereCondition("examined = ?", "N");
		PageBean pageBean = businessBillExtService.getPageBean(pageNum, 10, hqlHelper);
		outJson(JSON.toJSONString(pageBean));
	}
	
	/**
	 * 反审核 审核业务单详情
	 * examined  Y N  审核 反审核
	 * id 数据id
	 * @author guo
	 * @return Y N
	 */
	public void toExaminedInBill(){
		if(businessBillService.examinedEntity(getModel().getId(),getModel().getExamined())){
			outJson("成功！");
		}else{
			outJson("失败！");
		}
	}
	
	/**
	 * 作废 反作废 业务单详情
	 * enable 作废 反作废 
	 * id  执行数据的id
	 * @author guo
	 * @return Y N
	 */
	/*public void toEnableInBill(){
		if(businessBillService.cancelEntity(getModel().getId(),getModel().getEnabled())){
			outJson("成功！");
		}else{
			outJson("失败！");
		}
	}*/
	
	/**
	 * 获取为作废业务单详情
	 * enable  Y N 作废 反作废
	 * pageNum  页码
	 * @author guo
	 * @return JSON
	 */
	/*public void UnEnableInBill(){
		HqlHelper hqlHelper = new HqlHelper(BusinessBill.class, "businessBill").addWhereCondition("enable = ?", getModel().getEnabled());
		PageBean pageBean = businessBillService.getPageBean(pageNum, 10, hqlHelper);
		outJson(JSON.toJSONString(pageBean));
	}*/
}
